home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / mmdf / mmdf-IIb.43 / src / submit / hdr_parse.c < prev    next >
Encoding:
C/C++ Source or Header  |  1986-02-01  |  2.9 KB  |  96 lines

  1. #include "util.h"
  2. #include "mmdf.h"
  3. #include "hdr.h"
  4. /*
  5.  *     MULTI-CHANNEL MEMO DISTRIBUTION FACILITY  (MMDF)
  6.  *     
  7.  *
  8.  *     Copyright (C) 1979,1980,1981  University of Delaware
  9.  *     
  10.  *     Department of Electrical Engineering
  11.  *     University of Delaware
  12.  *     Newark, Delaware  19711
  13.  *
  14.  *     Phone:  (302) 738-1163
  15.  *     
  16.  *     
  17.  *     This program module was developed as part of the University
  18.  *     of Delaware's Multi-Channel Memo Distribution Facility (MMDF).
  19.  *     
  20.  *     Acquisition, use, and distribution of this module and its listings
  21.  *     are subject restricted to the terms of a license agreement.
  22.  *     Documents describing systems using this module must cite its source.
  23.  *
  24.  *     The above statements must be retained with all copies of this
  25.  *     program and may not be removed without the consent of the
  26.  *     University of Delaware.
  27.  *     
  28.  *
  29.  *     version  -1    David H. Crocker    March   1979
  30.  *     version   0    David H. Crocker    April   1980
  31.  *     version  v7    David H. Crocker    May     1981
  32.  *     version   1    David H. Crocker    October 1981
  33.  *
  34.  */
  35.  
  36. extern struct ll_struct *logptr;
  37.  
  38. /* basic processing of incoming header lines */
  39.  
  40. hdr_parse (src, name, contents)   /* parse one header line              */
  41.     register char *src;           /* a line of header text              */
  42.     char *name,                   /* where to put field's name          */
  43.      *contents;               /* where to put field's contents      */
  44. {
  45.     extern char *compress ();
  46.     char linetype;
  47.     register char *dest;
  48.  
  49. #ifdef DEBUG
  50.     ll_log (logptr, LLOGBTR, "hdr_parse()");
  51. #endif
  52.  
  53.     if (isspace (*src))
  54.     {                             /* continuation text                  */
  55. #ifdef DEBUG
  56.     ll_log (logptr, LLOGFTR, "cmpnt more");
  57. #endif
  58.     if (*src == '\n')
  59.         return (HDR_EOH);
  60.     linetype = HDR_MOR;
  61.     }
  62.     else
  63.     {                             /* copy the name                      */
  64.     linetype = HDR_NEW;
  65.     for (dest = name; *dest = *src++; dest++)
  66.     {
  67.         if (*dest == ':')
  68.         break;            /* end of the name                    */
  69.         if (*dest == '\n')
  70.         {                     /* oops, end of the line              */
  71.         *dest = '\0';
  72.         return (HDR_NAM);
  73.         }
  74.     }
  75.     *dest = '\0';
  76.     compress (name, name);    /* strip extra & trailing spaces      */
  77. #ifdef DEBUG
  78.     ll_log (logptr, LLOGFTR, "cmpnt name '%s'", name);
  79. #endif
  80.     }
  81.  
  82.     for (dest = contents; isspace (*src); )
  83.     if (*src++ == '\n')       /* skip leading white space           */
  84.     {                         /* unfulfilled promise, no contents   */
  85.         *dest = '\0';
  86.         return ((linetype == HDR_MOR) ? HDR_EOH : linetype);
  87.     }                          /* hack to fix up illegal spaces      */
  88.  
  89.     while ((*dest = *src) != '\n' && *src != 0)
  90.          src++, dest++;       /* copy contents and then, backup     */
  91.     while (isspace (*--dest));    /*   to eliminate trailing spaces     */
  92.     *++dest = '\0';
  93.  
  94.     return (linetype);
  95. }
  96.